import type { UserLabel } from "../projectManage/models";
import type { AuthorizedRoleFunctionsParams, RoleFunctionMenuItem } from "../role/models";
import type { EquipmentStatusItem, PropItem } from "/@/api/aiot/equipment/models";
import { AiotSubApp } from "/@/base/data";

export interface Diagram {
  projectId: string;
  diagramFiles: string;
  accessToken: string;
  createdOn: string;
  updatedOn: string;
  diagramId: string;
  scadaName: string;
  bindingState: 0 | 1;
  locationId: string;
  projectScadaId: string;
  equipments: string;
}

export type PartialDiagram = Partial<Diagram>;

export interface SetupLocationItem {
  key: string;
  address: string;
  description: string;
  indexOrder: number;
  locationId: string;
  locationName: string;
  locationTypeCode: "SYSTEM" | "BUILDING" | "FLOOR";
  locationTypeId: string;
  parentLocationId: string;
  parentLocationIds: string;
  projectId: string;
  children: SetupLocationItem[];
}

export enum SetupLocationType {
  system = "SYSTEM",
  floor = "FLOOR",
}

export interface CompBindEquipmentItem {
  compId: string;
  equipmentId: string;
  equipmentCode: string;
  paramKey?: string;
  paramName?: string;
  paramUnit?: string;
  propItem?: PropItem | null;
  status?: EquipmentStatusItem["equipmentStatus"] | null;
}

export interface ProjectRoleItem {
  projectId: string;
  projectRoleDescription: string;
  projectRoleId: string | "SYSTEM_ROLE_MANAGER" | "SYSTEM_ROLE_OPERATION" | "SYSTEM_ROLE_CUSTOMER";
  projectRoleName: string;
  projectRolePermissions: AuthorizedRoleFunctionsParams["roleMenuPermissions"];
  //前三个系统默认，LEADER拥有全部权限，TENANT用户自定义的项目角色
  projectRoleType: "LEADER" | "OPERATION" | "CUSTOMER" | "TENANT";
  disableOper?: boolean;
}

export type PartProjectRoleItem = Partial<ProjectRoleItem>;

export interface AddProjectMembersParam {
  applicationPermissions: AiotSubApp[];
  orgUserIds: string[];
  projectId: string;
  projectRoleId: string;
  subAccounts: { phone: string; userName: string }[];
}

export interface ProjectPermission {
  projectRoleType: ProjectRoleItem["projectRoleType"];
  projectRolePermissions: RoleFunctionMenuItem[] | null;
}
